//////////Change the directory before running the code
/////////////// Panel A
cd "D:\data&code"
////// Number of votes per event
use pseudo_dataset/voting, clear
bysort     pf_no : gen num_votes = _N
by pf_no : keep if _n == 1
tabstat num_votes, by(contest)

////// Number of events
use pseudo_dataset/voting, clear
keep pf_no contest
bysort pf_no : keep if _n == 1
tab contest

////// Support rates
use pseudo_dataset/voting, clear

mark fm if vote_num == 0
mark pm if vote_num == 0.25
mark ab if vote_num == 0.5
mark pd if vote_num == 0.75
mark fd if vote_num == 1
	
sort contest
by contest : tab fm
by contest : tab pm
by contest : tab ab
by contest : tab pd
by contest : tab fd

////// Dissident characteristics
use pseudo_dataset/voting, clear
bysort pf_no : keep if _n == 1

tabstat hf, 			by(contest)
tabstat no_camp,        by(contest)
tabstat share_intensity, by(contest)

/////////////// Panel B

/// Active vs passive
use pseudo_dataset/voting, clear
bysort passive contest : egen support = mean(for_diss)
by passive contest : keep if _n == 1
keep passive contest support

reshape wide support, i(passive) j(contest)
rename support1 voted
rename support2 settled
rename support3 withdrawn 

gen group = ""
replace group = "active"  if passive == 0
replace group = "passive" if passive == 1
drop passive
order group

tempfile x
save `x', replace 

/// B3 vs nonB3
use pseudo_dataset/voting, clear
keep if passive == 1
bysort big3 contest : egen support = mean(for_diss)
by big3 contest : keep if _n == 1
keep big3 contest support

reshape wide support, i(big3) j(contest)
rename support1 voted
rename support2 settled
rename support3 withdrawn

gen group = ""
replace group = "big3"  if big3 == 1
replace group = "xbig3" if big3 == 0 
drop big3
order group
sort group

tempfile y
save `y', replace 

/// Combine the two
use `x', clear
append using `y'

replace voted     = 100 * voted
replace settled   = 100 * settled
replace withdrawn = 100 * withdrawn

format voted     %3.2f
format settled   %3.2f
format withdrawn %3.2f

